package com.hhe.datax_transfer.component;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.hhe.datax_transfer.common.StringDefine;
import org.springframework.stereotype.Component;

/**
 * 数据迁移组件
 *
 * @author HHe
 * @version V1.0
 * @date 2021/1/8 16:14
 */
@Component
public class TransferComponent {
    /**
     * 获取当前项目路径
     *
     * @return {@link String}
     * @version V1.0
     * @author HHe
     * @date 2021/1/8 16:15
     */
    public String getLocalProjectPath() {

        return StrUtil.removePrefix(StrUtil.removeSuffix(FileUtil.normalize(System.getProperty("user.dir")), StringDefine.PROJECT_NAME), "file:");
//        return StrUtil.removePrefix(StrUtil.removeSuffix(FileUtil.normalize(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()), StringDefine.PROJECT_NAME), "file:");
//        return StrUtil.removeSuffix(FileUtil.normalize(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()), StringDefine.PROJECT_NAME);
    }

}
